<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>管理后台登录</title>

    <!--图标库 可无视-->
    <link rel='stylesheet' href='../css/font-awesome.min.css'>

    <!--核心样式-->
    <link rel="stylesheet" href="../css/admin/style.css">
    <style type="text/css">

    </style>
</head>
<body>

<div class="container" style="max-width: none">
    <div class="card"></div>
    <div class="card">
        <form>
            <input id="aid" value="{$editId}" style="display: none"/>
            <div class="input-container" style="margin-left: 20%;margin-right: 20%">
                <input type="password" id="oldPsw" required="required"/>
                <label for="oldPsw">原密码</label>
                <div class="bar"></div>
            </div>
            <div class="input-container" style="margin-left: 20%;margin-right: 20%">
                <input type="password" id="newPsw" name="newPsw" required="required"/>
                <label for="newPsw">新密码</label>
                <div class="bar"></div>
            </div>
            <div class="input-container" style="margin-left: 20%;margin-right: 20%">
                <input type="password" id="newPsw1" name="newPsw" required="required"/>
                <label for="newPsw1">确认密码</label>
                <div class="bar"></div>
            </div>
            <div class="button-container">
                <button type="button" onclick="editPsw()"><span>提交</span></button>
            </div>
        </form>
    </div>

</div>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script src="../js/plugins/layer/layer.min.js"></script>
<script>
    function editPsw() {
        var data = {}
        data['aid'] = $('#aid').val()
        data['oldPsw'] = $('#oldPsw').val()
        data['newPsw'] = $('#newPsw').val()
        data['newPsw1'] = $('#newPsw1').val()
        if (data['newPsw'] != data['newPsw1']) {
            layer.msg('新密码不一致')
            return
        }
        $.ajax({
            url: 'editPsw',
            type: 'POST',
            data: data,
            dataType: 'json',
            success: function (res) {
                if (res.code != 200) {
                    layer.msg(res.error)
                } else {
                    layer.msg('修改成功')
                    if (res.data.is_own == 1)
                        parent.location.reload();
                    else
                        self.location = document.referrer
                }
            },
        });
    }
</script>
</body>
</html>

